﻿using System;
using System.Linq;
using System.Linq.Expressions;

namespace SellAndBuy.Domain.Core
{
    /// <summary>
    /// Contract for query finders
    /// </summary>
    /// <typeparam name="TDTO"></typeparam>
    public interface IFinder<TDTO>
    {
        /// <summary>
        /// Get all elements
        /// </summary>
        /// <returns>List of elements</returns>
        IQueryable<TDTO> FindAll();

        /// <summary>
        /// Get all elements (Paged)
        /// </summary>
        /// <param name="pageIndex">Page index</param>
        /// <param name="pageCount">Page count</param>
        /// <returns></returns>
        IQueryable<TDTO> FindAll(int pageIndex, int pageCount);

        /// <summary>
        /// Get all by query (Expression)
        /// </summary>
        /// <param name="query">Expression to evaluate</param>
        /// <returns>List of qualified entities</returns>
        IQueryable<TDTO> FindBy(Expression<Func<TDTO, bool>> query);

        /// <summary>
        /// Get all by query (Expression) (Paged)
        /// </summary>
        /// <param name="query">Expression to evaluate</param>
        /// <param name="pageIndex">Page Index</param>
        /// <param name="pageCount">Page Count</param>
        /// <returns></returns>
        IQueryable<TDTO> FindBy(Expression<Func<TDTO, bool>> query, int pageIndex, int pageCount);
    }
}
